//index.js
//获取应用实例
const app = getApp()

Page({
  data: {    
    imgUrls: [],
    indicatorDots: true,
    autoplay: true,
    interval: 10000,
    duration: 1000,
    spotlist:[]
  },  
  onLoad: function () {
    wx.showLoading({
      title: '加载中'
    });
    //产品列表
    var that = this;
    wx.request({
      url: app.globalData.host + 'api/spot/list',
      method: 'POST',
      data: {
        user_id: '4',
        secret_key: '123456'
      },
      success: function (e) {        
        that.setData({ spotlist: e.data.body.data})       
      }
    });
    //幻灯片
    wx.request({
      url: app.globalData.host + 'api/article/get_rolling_ad',
      method: 'POST',
      data: {
        user_id: '4',
        secret_key: '123456',
        body:{
          name:'wxapp'
        }
      },
      success: function (e) {
        that.setData({ imgUrls: e.data.body.aditems});       
      }
    });
    wx.hideLoading();
  },
  //跳转列表页
  toList: function(e){
    wx.navigateTo({
      url: '/pages/list/index?ptype=' + e.currentTarget.dataset.type,
    })   
  },
  //跳转详细页
  toDetailsTap:function(e){
    wx.navigateTo({
      url: '/pages/detail/index?id=' + e.currentTarget.dataset.id + '&ptype=spot',
    })    
  }  
})
